package com.example.usermanager.tools;

import com.example.usermanager.model.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:咭咭熊
 * Date:2021 - 07 - 26
 * Time:15:10
 */
public class SessionUtil {
    /***
     * 获取Session中的用户对象
     * @param request
     * @return
     */
    public static UserInfo getUserBySession(HttpServletRequest request){

        HttpSession session = request.getSession(false);
        UserInfo userinfo = null;
        if(session != null && (userinfo = (UserInfo) session.getAttribute(AppFinal.USERINFO_SESSION_KEY ))!= null){}
        return userinfo;
    }

}
